package buildinjava.ant;

import buildinjava.Project;
import org.apache.tools.ant.BuildException;

/**
 * Builds a project.
 * 
 * @author Gili Tzabari
 */
public final class BuildTask extends AbstractAntTask
{
	private String configurationName;

	/**
	 * Sets the project configuration.
	 *
	 * @param configuration the configuration
	 * @throws IllegalArgumentException if configuration is null
	 */
	public void setConfiguration(String configuration) throws IllegalArgumentException
	{
		if (configuration == null)
			throw new IllegalArgumentException("configuration may not be null");
		this.configurationName = configuration;
	}

	@Override
	public void onExecute(Project project) throws BuildException
	{
		if (configurationName == null)
			throw new BuildException("configuration must be specified");
		project.getConfigurationByName(configurationName).build();
	}
}
